package com.czkevin.guicontrolsapi.controls;

import org.bukkit.inventory.ItemStack;

public abstract class AbstractSingleItemControl extends GUIControl{

    protected ItemStack display;

    protected abstract ItemStack createDisplay();

    public ItemStack getDisplayItem() {
        if(display == null) display = createDisplay();
        return display;
    }

    public void setDisplayItem(ItemStack display) {
        this.display = display;
    }

    @Override
    public void onRender(boolean force) {
        if(!force) return;
        getWindow().setDisplayItemAt(getX(), getY(), getDisplayItem());
    }
}
